#!/bin/bash
ip_list="10.1.1.81 10.1.1.83 10.1.11.159"
port=9100
function main() {
for ip in $ip_list
  do
    result=`echo -e "\n" |timeout --signal=9 2 telnet $ip $port 2>/dev/null | grep Connected | wc -l`
    if [ $result -ne 1 ]
    then
       echo $ip  >> $HOME/ip_refused.txt
    fi
  done
}
main